import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBNavigator.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBWorkTaiModule/YBFenXiangHuKePage/YBBaseProvider/YBBaseProvider.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/yb_jujidi_main/yb_jujidi_main_oneimagecell.dart';

class YBMineChuangZuoCenterMain extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
       child: DefaultTabController(
         length: 2,
         child: Scaffold(
           appBar: AppBar(
            elevation: 0,
            bottom: TabBar(
              tabs:[
               Tab(text: "我创作的",),
               Tab(text: "我转载的",),
            ]),
           ),
           body:TabBarView(
             children:[
               Container(
                 child: ChangeNotifierProvider(
                   create: (context) => YBMyDeWenZhangProvider()..getWodeDataList(1,orginType:"1"),
                   child: Consumer<YBMyDeWenZhangProvider>(
                       builder:(context,woZhuangList,child){
                     return SmartRefresher(
                        controller: woZhuangList.easyRefreshController,
                        onLoading: () async {
                           woZhuangList.loadData(orginType: "1");
                        },
                        enablePullDown: true,
                        enablePullUp: true,
                        onRefresh: () async {
                          woZhuangList.refreshData(orginType: "1");
                        },
                        child:ListView.builder(
                            itemBuilder:(BuildContext context,int index){
                              return Container(
                                child: InkWell(
                                  child: YBJuJiDiOneImageCell(),
                                  onTap: () async {
                                    YBNavigatorUtil.jump(context, '/workTaiPage/workTaiMyInfoDetailPage?id=${"reMenModel.id"}&&title=${Uri.encodeComponent("reMenModel.title")}&&descirtion=${Uri.encodeComponent("reMenModel.subTitle")}');
                                  },
                                ),
                              );
                          },itemCount: woZhuangList.woDeModelList.length,),
                      );
                   }),
                 ),
               ),
               Container(
                 child:  ChangeNotifierProvider(
                   create: (context) => YBMyDeWenZhangProvider()..getWodeDataList(1,orginType:"2"),
                   child: Consumer<YBMyDeWenZhangProvider>(
                       builder:(context,woZhuangList,child){
                         print("---我转载的-${woZhuangList.woDeModelList}--");
                         return SmartRefresher(
                           controller: woZhuangList.easyRefreshController,
                           onLoading: () async {
                             woZhuangList.loadData(orginType: "2");
                           },
                           enablePullDown: true,
                           enablePullUp: true,
                           onRefresh: () async {
                             woZhuangList.refreshData(orginType: "2");
                           },
                           child:ListView.builder(
                             itemBuilder:(BuildContext context,int index){
                               return Container(
                                 child: InkWell(
                                   child: YBJuJiDiOneImageCell(),
                                   onTap: () async {
                                     YBNavigatorUtil.jump(context, '/workTaiPage/workTaiMyInfoDetailPage?id=${"reMenModel.id"}&&title=${Uri.encodeComponent("reMenModel.title")}&&descirtion=${Uri.encodeComponent("reMenModel.subTitle")}');
                                   },
                                 ),
                               );
                             },itemCount: woZhuangList.woDeModelList.length,),
                         );
                       }),
                 ),
               ),
             ],
           ),
         ),
       ),
    );
  }
}
